<template>
<view class="container">
    <view class="withdrawal-box">
        <view class="withdrawal-item pay title">编号</view>
        <view class="withdrawal-item time title">申请日期</view>
        <view class="withdrawal-item price title">金额</view>
        <view class="withdrawal-item status title">状态</view>
    </view>
    <view v-for="(item, index) in withdrawals" :key="index" class="withdrawal-box">
        <view class="withdrawal-item pay">{{item.id}}</view>
        <view class="withdrawal-item time">{{item.createTimeFommat}}</view>
        <view class="withdrawal-item price">{{item.money}}</view>
        <view class="withdrawal-item status">
        {{item.status==0?'申请中':''}}{{item.status==1?'申请成功':''}}{{item.status==2?'提现完成':''}}
        {{item.status==3?'转款失败':''}}{{item.status== -2?'审核作废':''}}{{item.status==-1?'审核失败':''}}
        </view>
    </view>
</view>
</template>

<script>
var app = getApp();
import LoadMore from "../../../utils/LoadMore";
var load = new LoadMore();
var util = require("../../../utils/util.js");

export default {
  data() {
    return {
      url: app.globalData.setting.url,
      resourceUrl: app.globalData.setting.resourceUrl,
      withdrawals: null,
      //请求的充值记录
      currentPage: 1,
      type: 0
    };
  },

  components: {},
  props: {},
  onLoad: function (options) {
    if (options && options.type) {
      this.setData({
        type: options.type
      });
    }

    load.init(this, '', 'withdrawals');
    this.requestWithdrawalsList();
  },
  onReachBottom: function () {
    if (load.canloadMore()) {
      this.requestWithdrawalsList();
    }
  },
  onPullDownRefresh: function () {
    this.withdrawals = null;
    this.currentPage = 1;
    load.resetConfig();
    this.requestWithdrawalsList();
  },
  methods: {
    requestWithdrawalsList: function () {
      var that = this;
      var requestUrl = '/api/user/withdrawals_list/type/' + that.type + '?p=' + that.currentPage;
      load.request(requestUrl, function (res) {
        that.currentPage++;
        res.data.result.forEach(function (val, index, arr) {
          val.createTimeFommat = util.format(val.create_time, 'yyyy-MM-dd');
        });
        uni.stopPullDownRefresh();
      });
    }
  }
};
</script>
<style>
page{
    background-color: #f5f5f5;
}
.container{
    padding: 20rpx 20rpx;
}
.withdrawal-box{
    background: #F0F0F0;
    font-size: 26rpx;
    color: #666666;
    width: 100%;
    padding: 20rpx 0;
    border-radius: 10rpx;
}
.withdrawal-item{
    display: inline-block; 
    width: 25%;
    word-break: keep-all;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    color: #666;
}
/* .withdrawal-box .pay{
    width: 20%;
}
.withdrawal-box .time{
    width: 27%;
}
.withdrawal-box .price{
    width: 28%;
}
.withdrawal-box .status{
    width: 25%;
    color: #ff6a00;
} */
/* .withdrawal-box .title{
    color: #666666;
    font-size: 32rpx;
} */
.withdrawal-box{
    width: 100%;
    font-size: 28rpx;
    padding: 20rpx 0;
    border-radius: 10rpx;
    /* padding-left: 5rpx; */
}
.withdrawal-box:nth-child(odd){
    background: #fff;
}
.withdrawal-box:nth-child(even){
    background: #FAFAFA;
}
.withdrawal-item{
    display: inline-block; 
    width: 25%;
    word-break: keep-all;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    color: #666;
}
.withdrawal-box .cont{
    color: #808080;
}
.withdrawal-box .price{
    color: #ff6a00; 
    text-align: center;
}
.withdrawal-box .time{
    color: #808080;
}
.withdrawal-box .status{
    color:  #808080;
}
.withdrawal-box .title{
    text-align: center;
}

</style>